package logic

import (
	"context"
	"rpc/model/redis"

	"rpc/internal/svc"
	"rpc/pb/cart"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartAmountLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartAmountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartAmountLogic {
	return &CartAmountLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartAmountLogic) CartAmount(in *cart.CartAmountRequest) (*cart.CartAmountResponse, error) {
	// todo: add your logic here and delete this line
	amount := redis.CartAmount(in.UserId)

	return &cart.CartAmountResponse{Amount: float32(amount)}, nil
}
